/**
* Copyright (c) 2022 - present TinyVue Authors.
* Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

@import '../custom.less';
@import './vars.less';

@file-upload-prefix-cls: ~'@{css-prefix}file-upload';
@upload-list-prefix-cls: ~'@{css-prefix}upload-list';
@progress-prefix-cls: ~'@{css-prefix}progress';
@icon-close-tip-prefix-cls: ~'@{css-prefix}icon-close-tip';
@icon-check-prefix-cls: ~'@{css-prefix}icon-check';
@svg-prefix-cls: ~'@{css-prefix}svg';
@tooltip-prefix-cls: ~'@{css-prefix}tooltip';

.@{file-upload-prefix-cls} {
  .component-css-vars-upload-list();

  &.@{tooltip-prefix-cls} {
    margin-bottom: 7px;
  }
}

.@{upload-list-prefix-cls} {
  margin: 0;
  padding: 0;
  list-style: none;

  &__wrapper {
    display: inline;
  }

  a:hover {
    color: #333;
    text-decoration: var(--ti-upload-list-item-hover-text-decoration);
  }

  // 提高优先级覆盖ul.li样式
  &--text {
    li:first-of-type > .@{upload-list-prefix-cls}__item {
      margin-top: calc(var(--ti-upload-list-item-margin-top) + 3px);
    }

    li:not(:first-of-type) > .@{upload-list-prefix-cls}__item {
      margin-top: var(--ti-upload-list-item-margin-top);
    }

    li:last-of-type {
      margin-bottom: 8px;
    }

    li + li {
      .@{upload-list-prefix-cls}__item.is-uploading,
      .@{upload-list-prefix-cls}__item.is-downloading {
        margin-top: 18px;
        margin-bottom: 18px;
      }
    }
  }

  &__item.is-fail {
    .@{upload-list-prefix-cls}__item-name {
      color: var(--ti-upload-list-item-fail-text-color);
      & .tiny-svg {
        fill: var(--ti-upload-list-item-fail-text-color);
      }
    }
  }

  &__item {
    transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
    font-size: var(--ti-upload-list-item-font-size);
    color: var(--ti-upload-list-item-text-color);
    line-height: var(--ti-upload-list-item-line-height);
    position: relative;
    box-sizing: border-box;
    border-radius: var(--ti-upload-list-item-border-radius);
    width: 100%;
    outline: none;

    &:hover {
      background-color: var(--ti-upload-list-item-hover-background-color);

      .@{svg-prefix-cls}.icon-close,
      .@{svg-prefix-cls}.icon-refres {
        display: inline-block;
      }

      .@{progress-prefix-cls}__text {
        display: none;
      }
    }

    &.is-success {
      .@{upload-list-prefix-cls}__item-status-label {
        display: block;
      }

      .@{upload-list-prefix-cls}__item-name:focus,
      .@{upload-list-prefix-cls}__item-name:hover {
        color: var(--ti-upload-list-item-hover-text-color);
        cursor: pointer;
        text-decoration: none;
      }

      &:focus:not(:hover) .@{icon-close-tip-prefix-cls} {
        display: inline-block;
      }

      &:active,
      &:not(.focusing):focus {
        outline-width: 0;
      }

      &:active .@{icon-close-tip-prefix-cls},
      &:focus .@{upload-list-prefix-cls}__item-status-label,
      &:hover .@{upload-list-prefix-cls}__item-status-label,
      &:not(.focusing):focus .@{icon-close-tip-prefix-cls} {
        display: none;
      }
    }

    &.is-disabled &:hover &-status-label {
      display: block;
    }

    &.isEdm {
      .@{upload-list-prefix-cls}__item-name {
        display: inline-block;

        &.isFail {
          color: red;
        }
      }

      .@{upload-list-prefix-cls}__item-edminfo {
        margin-right: 46px;
      }

      .@{upload-list-prefix-cls}__item-status-label {
        right: 16px;
      }

      &:not(.showUpdate) {
        .icon-refres {
          display: none;
        }
      }

      &:not(.showDel) {
        .icon-close {
          display: none;
        }
      }

      &.showUpdate {
        .icon-refres {
          right: 16px;
        }
      }

      &.showDel {
        .icon-close {
          right: 16px;
        }
      }

      &.showUpdate.showDel {
        .icon-refres {
          right: 28px;
        }

        .icon-close {
          right: 8px;
        }
      }

      &:not(.showUpdate):not(.showDel) {
        .@{upload-list-prefix-cls}__item-status-label {
          display: block;
        }
      }
    }

    .@{progress-prefix-cls} {
      position: absolute;
      top: var(--ti-upload-list-item-progress-top);
      width: 100%;
    }

    .@{progress-prefix-cls}__text {
      position: absolute;
      right: 0;
      top: -13px;
    }

    .@{progress-prefix-cls}-bar {
      margin-right: 0;
      padding-right: 0;
    }

    .@{svg-prefix-cls} {
      &.icon-successful {
        font-size: var(--ti-upload-list-successful-icon-font-size);
        fill: var(--ti-upload-list-successful-status-bg-color);
      }

      &.icon-close {
        display: none;
        position: absolute;
        top: 50%;
        right: var(--ti-upload-list-svg-close-position-right);
        transform: translateY(-50%);
        fill: var(--ti-upload-list-svg-close-icon-color);
        font-size: var(--ti-upload-list-svg-icon-font-size);
        opacity: 0.75;
        cursor: pointer;

        &:hover {
          opacity: 1;
        }
      }

      &.icon-refres {
        display: none;
        position: absolute;
        top: 50%;
        right: var(--ti-upload-list-svg-refresh-position-right);
        transform: translateY(-50%);
        fill: var(--ti-upload-list-svg-close-icon-color);
        font-size: var(--ti-upload-list-svg-icon-font-size);
        opacity: 0.75;
        cursor: pointer;

        &:hover {
          opacity: 1;
        }
      }
    }

    .@{icon-close-tip-prefix-cls} {
      display: none;
      position: absolute;
      top: 5px;
      right: 5px;
      font-size: var(--ti-upload-list-svg-icon-font-size);
      cursor: pointer;
      opacity: 1;
      color: var(--ti-upload-list-item-hover-text-color);
    }
  }

  &__item-edminfo,
  &__item-folder {
    display: inline-block;
    vertical-align: top;
  }

  &__item-edminfo {
    margin-right: 20px;

    span {
      display: inline-block;
      margin-right: 10px;
    }

    &.isFail span {
      color: #f5222d;
    }
  }

  &__text-title {
    display: flex;
    align-items: center;
    font-size: 14px;
    height: 22px;
    line-height: 22px;
    color: var(--ti-upload-list-item-fail-text-color);
  }

  &__icon-operationfaild {
    fill: #f23030;
    margin-right: 9px;
    padding-left: 4px;
    font-size: 16px;
  }

  &__item-tooltip {
    display: flex;
    align-items: center;
    line-height: 1.5;
  }

  &__item-name {
    color: var(--ti-upload-list-item-text-color);
    display: block;
    margin-right: 40px;
    padding-left: 4px;
    transition: color 0.3s;

    .@{svg-prefix-cls} {
      font-size: var(--ti-upload-list-item-name-icon-font-size);
      margin-right: 4px;
      fill: var(--ti-upload-list-item-name-icon-color);
    }
  }

  &__item-status-label {
    position: absolute;
    right: 5px;
    top: 0;
    line-height: inherit;
    display: none;
  }

  &__item-delete {
    position: absolute;
    right: 10px;
    top: 0;
    font-size: var(--ti-upload-list-svg-icon-font-size);
    color: var(--ti-upload-list-svg-close-icon-color);
    display: none;

    &:hover {
      color: var(--ti-upload-list-item-hover-text-color);
    }
  }

  &__download-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
  }

  &--picture-card {
    margin: 0;
    display: inline;
    vertical-align: top;

    .@{upload-list-prefix-cls}__li {
      display: inline-block;

      .is-fail {
        color: var(--ti-upload-list-item-fail-text-color);
      }

      &-title:not(.is-fail) {
        color: #595959;
      }

      &-title {
        margin-top: -4px;
        text-align: center;
        line-height: 1.5;
        width: var(--ti-upload-list-picture-card-width);
        height: 18px;
        font-size: 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }

    .@{upload-list-prefix-cls}__item {
      overflow: hidden;
      background-color: var(--ti-upload-list-picture-card-item-bg-color);
      border: 1px solid var(--ti-upload-list-picture-card-item-border-color);
      border-radius: var(--ti-upload-list-item-border-radius);
      box-sizing: border-box;
      width: var(--ti-upload-list-picture-card-width);
      height: var(--ti-upload-list-picture-card-height);
      margin: 0 var(--ti-upload-list-picture-card-item-margin-right) 8px 0;
      display: inline-block;

      &.is-fail {
        border-color: var(--ti-upload-list-item-fail-text-color);
        background-color: rgba(242, 48, 48, 0.1);

        .@{upload-list-prefix-cls}__item-actions:hover {
          background-color: rgba(242, 48, 48, 0.1);

          & span .tiny-svg {
            fill: #191919;
          }
        }
      }

      .@{icon-check-prefix-cls} {
        fill: var(--ti-upload-list-picture-card-item-text-color);
      }

      .@{svg-prefix-cls}.icon-close,
      .@{svg-prefix-cls}.icon-refres,
      &:hover .@{upload-list-prefix-cls}__item-status-label {
        display: none;
      }

      &:hover .@{progress-prefix-cls}__text {
        display: block;
      }
    }

    .@{upload-list-prefix-cls}__item-name {
      display: none;
    }

    .@{upload-list-prefix-cls}__item-thumbnail {
      width: 100%;
      height: 100%;
    }

    .@{upload-list-prefix-cls}__item-status-label {
      position: absolute;
      right: -15px;
      top: -6px;
      width: 40px;
      height: 24px;
      background: var(--ti-upload-list-successful-status-bg-color);
      text-align: center;
      transform: rotate(45deg);
      box-shadow: 0 0 1pc 1px rgba(0, 0, 0, 0.2);

      .@{svg-prefix-cls} {
        font-size: var(--ti-upload-list-svg-icon-font-size, 12px);
        margin-top: 11px;
        transform: rotate(-45deg);
      }
    }

    .@{upload-list-prefix-cls}__item-actions {
      position: absolute;
      width: 100%;
      height: 100%;
      left: 0;
      top: 0;
      cursor: default;
      text-align: center;
      fill: var(--ti-upload-list-picture-card-item-icon-color);
      opacity: 0;
      font-size: var(--ti-common-font-size-4);
      background-color: var(--ti-upload-list-picture-card-item-hover-bg-color);
      transition: opacity 0.3s;

      &::after {
        display: inline-block;
        content: '';
        height: 100%;
        vertical-align: middle;
      }

      &:hover {
        opacity: 1;

        span {
          display: inline-block;
        }
      }

      span {
        display: none;
        cursor: pointer;

        & + span {
          margin-left: 15px;
        }
      }

      .@{upload-list-prefix-cls}__item-preview {
        .tiny-svg-fullscreen {
          transform: rotate(90deg);
        }
      }

      .@{upload-list-prefix-cls}__item-delete,
      .@{upload-list-prefix-cls}__item-refres {
        position: static;
        font-size: inherit;
        color: inherit;
      }
    }

    .@{progress-prefix-cls} {
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      bottom: auto;
      width: var(--ti-upload-list-picture-card-progress-size);

      .@{progress-prefix-cls}__text {
        top: 50%;
      }
    }

    // smb取消上传功能
    .@{upload-list-prefix-cls}__item-cancel {
      position: absolute;
      left: 50%;
      bottom: 16px;
      transform: translateX(-50%);
      font-size: 14px;
      color: #1476ff;
      line-height: 22px;
      letter-spacing: 0;
      white-space: nowrap;
      cursor: pointer;
    }
  }

  &--picture &__item {
    overflow: hidden;
    z-index: 0;
    background-color: var(--ti-upload-list-picture-card-item-bg-color);
    box-sizing: border-box;
    margin-top: 8px;
    outline: 0;

    .@{icon-check-prefix-cls} {
      fill: var(--ti-upload-list-picture-card-item-text-color);
    }

    &:hover {
      .@{upload-list-prefix-cls}__item-status-label {
        background: 0 0;
        box-shadow: none;
        top: -2px;
        right: -12px;
      }

      .@{progress-prefix-cls}__text {
        display: block;
      }
    }

    &.is-success {
      .@{upload-list-prefix-cls}__item-name {
        line-height: 56px;
        margin-top: 0;

        .@{svg-prefix-cls} {
          display: none;
        }
      }
    }
  }

  &--picture &__item-thumbnail {
    width: 56px;
    height: 56px;
    border: 1px solid var(--ti-upload-list-picture-card-item-border-color);
    border-radius: var(--ti-upload-list-item-border-radius);
    float: left;
    position: relative;
    z-index: 1;
    vertical-align: middle;
    margin-right: 12px;
  }

  &--picture &__item-name {
    display: block;
    line-height: 56px;

    .@{svg-prefix-cls} {
      font-size: var(--ti-common-font-size-1);
    }
  }

  &--picture &__item-status-label {
    position: absolute;
    right: -17px;
    top: -7px;
    width: 46px;
    height: 26px;
    background: var(--ti-upload-list-successful-status-bg-color);
    text-align: center;
    transform: rotate(45deg);
    box-shadow: 0 1px 1px #ccc;

    .@{svg-prefix-cls} {
      font-size: var(--ti-upload-list-svg-icon-font-size);
      margin-top: 12px;
      transform: rotate(-45deg);
    }
  }

  &--picture .@{progress-prefix-cls} {
    position: relative;
    top: -7px;
  }
}

// 多端fileUpload组件文件上传列表样式
.@{upload-list-prefix-cls}--saas {
  border: 0px dashed #c9c9c9;

  &.border-zero {
    border-width: 0;
  }

  &.border-top {
    border-top-width: 1px;
  }

  &.mode-bubble {
    height: 208px;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .@{upload-list-prefix-cls}-panel {
    font-size: 0;

    .@{upload-list-prefix-cls}-item {
      position: relative;
      display: inline-block;
      min-width: 100%;
      padding: 12px;
      margin-right: 8px;
      border: 1px solid #dfdfdf;
      border-radius: 4px;

      &:hover {
        background-color: #f5f6f8;

        .operate-panel {
          visibility: visible;
        }
      }

      &.selected {
        border-color: #0067d1;
      }

      &.compact {
        min-width: 448px;
      }

      &:not(:last-child) {
        margin-bottom: 8px;
      }
    }
  }

  .@{upload-list-prefix-cls}-thumb {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    vertical-align: top;

    .uploading-mask {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      background-color: #000;
      opacity: 0.5;
      border-radius: 2px;
    }

    .uploading-progress {
      width: 100%;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      overflow: hidden;
      display: flex;
      padding: 0 4px;
      align-items: center;
      justify-content: center;
      border-radius: 2px;
    }

    .uploading-progress-panel {
      background-color: #aeaeae;
      width: 100%;
      height: 2px;
      border-radius: 2px;
    }

    .uploading-progress-bar {
      background-color: #fff;
      height: 100%;
      transition: all cubic-bezier(0.4, 0, 0.2, 1) 150ms;
    }

    .file-icon {
      width: 100%;
      height: 100%;
      border-radius: 2px;
    }

    .upload-fail {
      position: relative;
      width: 100%;
      height: 100%;
      border-radius: 2px;
      background-color: #fee7e8;
    }

    .upload-fail-icon {
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      fill: #e02128;
      font-size: 18px;
    }
  }

  .@{upload-list-prefix-cls}-content {
    position: relative;
    display: inline-block;
    width: calc(100% - 40px);
    font-size: 12px;

    .file-name {
      display: flex;
      height: 16px;
    }

    .file-name-box {
      flex: 1;
      margin-right: 24px;
      font-size: 12px;
      line-height: 12px;
      color: #191919;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    .operate-panel {
      visibility: hidden;
      min-width: fit-content;
      color: #2e86de;
      font-size: 12px;

      .operate-btn {
        cursor: pointer;
        margin-right: 8px;

        &:last-of-type {
          margin-right: 0px;
        }
      }
    }

    .file-size {
      display: flex;
      height: 16px;
      line-height: 20px;
    }

    .file-size-content {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      color: #aeaeae;

      .fail > span {
        color: #e7434a;
      }
    }

    .file-size-right {
      flex: 1;
      margin-left: 8px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      text-align: right;
      color: #aeaeae;
    }
  }

  .no-attachments {
    margin-top: 16px;
    color: #aeaeae;
    font-size: 12px;
  }
}
